<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS继承</title>
</head>
<body>
    <script>
        function Super(){
            this.subProps ="Super Props";
        }
      
        Super.prototype.getProps = function(){
            return this.subProps;
        }


        function Sub(){
            this.subProps ="Sub Props";
        }
        /* 函数对象的proptype上绑定属性,那么该函数对象的实例对象便自动拥有
          
        */
        var sup = new Super();
        Sub.prototype = sup;  //这里的原型属性指向一个实例对象
        Sub.prototype.setProps = function () {  // Sub.prototype.setProps是把函数设置给实例对象不影响函数对象
            console.log("override");
           
          }


        var sub = new Sub();
        console.log(sub.getProps());
        sup.setProps();
      
     

    

        
    








    </script>
</body>
</html>